import java.util.Random;

public class Lab_01 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] answers = new int[50]; // 存储答案的数组
        
        System.out.println("50道100以内的加减法口算练习题：");
        System.out.println("====================================");
        
        for (int i = 1; i <= 50; i++) {
            int num1 = random.nextInt(100); // 生成0-99的随机数
            int num2 = random.nextInt(100); // 生成0-99的随机数
            char operator = (random.nextBoolean()) ? '+' : '-';
            int answer;
            
            if (operator == '-') {
                if (num1 < num2) {
                    // 交换两个数
                    int temp = num1;
                    num1 = num2;
                    num2 = temp;
                }
                answer = num1 - num2;
            } else {
                answer = num1 + num2;
            }
            
            // 存储答案
            answers[i-1] = answer;
            
            System.out.println(i + ". " + num1 + " " + operator + " " + num2 + " = ");
        }
        
        System.out.println("\n答案：");
        System.out.println("====================================");
        
        // 输出答案
        for (int i = 0; i < 50; i++) {
            System.out.println((i+1) + ". " + answers[i]);
        }
        
        System.out.println("====================================");
    }
}